package com.hopu.ssm_demo.service.impl;

import com.hopu.ssm_demo.dao.UserMapper;
import com.hopu.ssm_demo.entity.User;
import com.hopu.ssm_demo.entity.UserExample;
import com.hopu.ssm_demo.service.IUserService;
import com.hopu.ssm_demo.service.IUserService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User业务逻辑实现
 */
@Service
public class UserServiceImpl2 implements IUserService2 {

    @Autowired
    private UserMapper userMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    public void insert1(){
        User user = new User();
        user.setUserName("内部事务");
        userMapper.insert2(user);
        throw new RuntimeException("异常");
    }

}
